package org.apache.flink.runtime.resourceprovider;

import java.util.concurrent.CompletableFuture;

/**
 * Simple adapter for {@link ResourceProvider} to adapt to {@link
 * ResourceProviderRunner.ResourceProviderService}.
 */
public class ResourceProviderToServiceAdapter implements ResourceProviderRunner.ResourceProviderService {

    private final ResourceProvider resourceProvider;

    private ResourceProviderToServiceAdapter(ResourceProvider taskExecutor) {
        this.resourceProvider = taskExecutor;
    }

    @Override
    public void start() {
        resourceProvider.start();
    }

    @Override
    public CompletableFuture<Void> getTerminationFuture() {
        return resourceProvider.getTerminationFuture();
    }

    @Override
    public CompletableFuture<Void> closeAsync() {
        return resourceProvider.closeAsync();
    }

    public static ResourceProviderToServiceAdapter createFor(ResourceProvider taskExecutor) {
        return new ResourceProviderToServiceAdapter(taskExecutor);
    }
}
